package com.example.cart_system.mapper;

import com.example.cart_system.pojo.Goods;
import com.example.cart_system.pojo.GoodsInfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface GoodsMapper {
    //添加商品
    @Insert("insert into goods (gid, gname, gimage, gprice) values (#{gid}, #{gname}, #{gimage}, #{gprice})")
    public void insertGoods(Goods goods);
    //商品列表
    @Select("select * from goods")
    public List<Goods> selectAllGoods();
    //删除商品
    @Delete("delete from goods where gid = #{gid}")
    public void deleteGoods(Goods goods);
    //根据商品gid选择商品，并添加商品信息
    @Select("select gid, gname, gimage, gprice from goods where gid = #{gid}")
    public GoodsInfo selectGoodByGid(String gid);
}
